<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="f_div">
        <li name="frist_li">sasa</li>
        <li>afaw</li>
        <li>rbrdsg</li>
    </div>

    <!---->
    <div class="comment_div">
        <ul class="comment_ul">
          <li>houdunren.com</li>
        </ul>
      </div>
      
    <script>
        //用于检测元素是否是指定的样式选择器匹配，下面过滤掉所有name属性的LI元素
        //querySelelctor的结果是object,querySelelctorAll的结果是数组
        console.log(document.querySelector(".f_div"));
        console.log(document.querySelectorAll("li"));
       let filter_li= [...document.querySelectorAll(".f_div li")].filter(v=>{
            return !v.matches('[name]');
        });
        console.log(filter_li);

        //closest,查找最近的父类元素
        let li=document.querySelectorAll('.comment_ul li');
        //查找最近的comment_ul
        console.log(li[0]);
        let closestElement=li[0].closest('.comment_ul');
        console.log(closestElement);//ul.comment_ul
    </script>
</body>
</html>